var ztreeMenu,nodeId,nodeName,level;
var setting = {
		data: {
			simpleData: {
				enable: true,
				idKey: "id",
				pIdKey: "pId",
				rootPId: 0
			}
		},
		callback:{
			onClick:zTreeOnClick
		}
};
//加载ztree  
function onloadZTree(){  
	var ztreeNodes;
	$.ajax({
		async : true, // 是否异步
		cache : false, // 是否使用缓存
		type : 'POST', // 请求方式,post
		dataType : "json", // 数据传输格式
		url : "/channel/treeAll", // 请求链接
		error : function() {
			alert('亲，网络有点不给力呀！');
		},
		success : function(data) {
			// ztreeNodes = eval( "["+data+"]" ); //将string类型转换成json对象
			ztreeNodes = data;
			$.fn.zTree.init($("#treeDemo"), setting, ztreeNodes);
			zTree_Menu = $.fn.zTree.getZTreeObj("treeDemo");
		}
	});  
}  

function zTreeOnClick(event, treeId, treeNode) {
    nodeId = treeNode.id;
    nodeName = treeNode.name;
    //var d = []; for(k in treeNode) d.push(k+":"+treeNode[k]); console.log(d);
    $("#channelIframe").attr("src","channels/"+treeNode.id);
};
 //初始化操作  
$(document).ready( function(){  
      onloadZTree();  
});  
 

	
